#pragma once

#include <fstream>
#include <vector>

#include "data_storage.hpp"

class GNSSFileLoader {
private:
    std::ifstream m_gnss_data_file;

public:
    GNSSFileLoader(std::string filename, double timestamp = -1);
    ~GNSSFileLoader() {}

    std::vector<iNav::GnssData> m_gnss_vec;
};

GNSSFileLoader::GNSSFileLoader(std::string filename, double timestamp)
    : m_gnss_data_file(filename.c_str()) {
    iNav::GnssData gnss_frame;
    while (!m_gnss_data_file.eof()) {
        m_gnss_data_file >> gnss_frame.timestamp >> gnss_frame.pos[0] >> gnss_frame.pos[1] >>
            gnss_frame.pos[2] >> gnss_frame.pos_std[0] >> gnss_frame.pos_std[1] >>
            gnss_frame.pos_std[2];
        if (gnss_frame.timestamp >= timestamp)
            m_gnss_vec.push_back(gnss_frame);
    }
}
